<?php

require_once "cnx.php";
require_once "ClassMovie.php";
require_once "ClassMovieDetail.php";

$action = $_POST["action"];
$id = $_POST["id"];

switch($action){

	case "disableDetail":
		$movieDetail = new MovieDetail();
		$movieDetail->code = $id;
		$movieDetail->disableMovieDetail();
		echo "1";
	break;
	case "loadDetail":
		$movieDetail = new MovieDetail();
		$movieDetail->code = $id;
		$movieDetail->loadMovieDetail();
/*
MovieDetail Object
(
    [code] => 188448
    [directors] => Alexandre de La Patelli�re, Matthieu Delaporte
    [actors] => Patrick Bruel, Val�rie Benguigui, Charles Berling, Guillaume De Tonqu�dec, Judith El Zein
    [pressRating] => 3.21053
    [userRating] => 4.05886
    [movieId] => 295
    [state] => 1
)

**/
		echo"<div id='contentDetails'>

		<div id='poster'><img class='poster' src='" . $movieDetail->posterURLLocal . "'></div>
		<div id='title'>" . utf8_encode($movieDetail->title) . "</div>
		<div id='synopsis'>" . $movieDetail->synopsis . "</div>
		<div id='productionYear'>Produit en : " . $movieDetail->productionYear . "</div>
		<div id='releaseDate'>Date de sortie : " . $movieDetail->releaseDate . "</div>
		<div id='directors'>Réalisé par : " . utf8_encode($movieDetail->directors) . "</div>
		<div id='actors'>Avec : " . utf8_encode($movieDetail->actors) . "</div>
		<div id='pressRating' class='rating' title='Presse :". round($movieDetail->pressRating,2) ."'>Presse :<div class='star-holder'><div class='star-rating' style='width: ". $movieDetail->pressRating*92/5 ."px'></div></div></div>
		<div id='userRating' class='rating'  title='Spectateurs :". round($movieDetail->userRating,2)  ."'>Spectateurs :<div class='star-holder'><div class='star-rating' style='width: ". $movieDetail->userRating*92/5  ."px'></div></div></div>

		</div>";
	break;

}